package com.star.domain;

import lombok.Getter;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;


/**
 * 实体基础类
 *
 * @author 孙星阳
 * @date 2017/9/29 下午1:49
 */
@SuppressWarnings("serial")
@MappedSuperclass
@Getter
public abstract class AbstractEntity implements Serializable {

    /**
     * 主键ID
     *
     * @author 孙星阳
     * @date 2017/9/29 下午1:47
     */
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    String id;
    /**
     * 创建者
     *
     * @author 孙星阳
     * @date 2017/9/29 下午1:48
     */
    @CreatedBy
    @Column(name = "created_by", nullable = false, length = 32, updatable = false)
    private String createdBy;
    /**
     * 修改者
     *
     * @author 孙星阳
     * @date 2017/9/29 下午1:48
     */
    @LastModifiedBy
    @Column(name = "modified_by", nullable = false, length = 32)
    private String modifiedBy;
    /**
     * 创建时间
     *
     * @author 孙星阳
     * @date 2017/9/29 下午1:48
     */
    @Column(name = "created_time")
    @CreatedDate
    Date createdDate;
    /**
     * 最后修改时间
     *
     * @author 孙星阳
     * @date 2017/9/29 下午1:49
     */
    @Column(name = "update_time")
    @LastModifiedDate
    Date modifiedDate;
}
